﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LEARNREN.COM.UI.Template;
using LEARNREN.COM.Entity;

namespace LEARNREN.COM.UI.LabelProviders
{
    /// <summary>
    /// 单页面标签
    /// </summary>
    class SGPLabel:AbstractLabelProvider
    {
        public SGPLabel(string label)
            : base(label)
        {

        }


        public override string GetHtml()
        {
            try
            {
                if (this.Context.Container is SinglePageTemplate)
                {
                    string[] paras = LabelProviderHelper.GetProperties(this.LabelString);
                    if (paras == null || paras.Length < 1)
                    {
                        return this.LabelString;
                    }
                    else
                    {
                        switch (paras[0].ToLower())
                        {
                            case "title":
                                return (this.Context.State as Catalogue).Title;
                            case "content":
                                return (this.Context.State as Catalogue).Content;
                            default:
                                return this.LabelString;                                
                        }
                    }
                }
                else
                {
                    return this.LabelString;
                }
            }
            catch 
            {
                return this.LabelString;
            }
        }
    }
}
